package com.k2fsa.sherpa.onnx

class OnlineStream(var ptr: Long = 0) {
    fun acceptWaveform(samples: FloatArray, sampleRate: Int) =
        acceptWaveform(ptr, samples, sampleRate)

    fun inputFinished() = inputFinished(ptr)

    protected fun finalize() {
        if (ptr != 0L) {
            delete(ptr)
            ptr = 0
        }
    }

    fun release() = finalize()

    private external fun acceptWaveform(ptr: Long, samples: FloatArray, sampleRate: Int)
    private external fun inputFinished(ptr: Long)
    private external fun delete(ptr: Long)

    companion object {
        init {
            System.loadLibrary("sherpa-onnx-jni")
        }
    }
}

//
//nohup bash run_server_2pass.sh --download-model-dir /workspace/models --vad-dir iic/speech_fsmn_vad_zh-cn-16k-common-onnx \
//--model-dir iic/SenseVoiceSmall  \
//--online-model-dir iic/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-online-onnx  \
//--punc-dir iic/punc_ct-transformer_zh-cn-common-vad_realtime-vocab272727-onnx \
//--lm-dir iic/speech_ngram_lm_zh-cn-ai-wesp-fst \
//--itn-dir thuduj12/fst_itn_zh \
//--hotword /workspace/models/hotwords.txt --certfile 0 > /var/log/yc_asr_log.txt 2>&1 &
//
//
//
//./run_server_2pass.sh --vad-dir /workspace/models/iic/speech_fsmn_vad_zh-cn-16k-common-onnx \
//--model-dir /workspace/models/iic/SenseVoiceSmall  \
//--punc-dir /workspace/models/iic/punc_ct-transformer_zh-cn-common-vad_realtime-vocab272727-onnx \
//--lm-dir /workspace/models/iic/speech_ngram_lm_zh-cn-ai-wesp-fst \
//--itn-dir /workspace/models/thuduj12/fst_itn_zh \
//--hotword /workspace/models/hotwords.txt --certfile 0